<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - <?php echo (C("INTENDANT_NAME")); ?> - by HemaCMS</title>
    <link href="/Public/intendant/css/admin_style.css" rel="stylesheet" />
    <script src="/Public/common/js/jquery.js"></script>
    <script src="/Public/common/js/jquery.cookie.js"></script>
    <script src="/Public/common/js/layer/layer.js"></script>
    <script src="/Public/intendant/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
    <link href="/Public/intendant/css/iteny.css" rel="stylesheet" />
    <style type="text/css">
    tr{border-left: 1px solid #e5e3e3;}
    td{border-right: 1px solid #e5e3e3;}
    </style>
</head>
<body>
<div class="wrap J_check_wrap">
   	<div class="nav">
  	    <ul class="cc">
  	        <li><a href="<?php echo U('Site/database');?>/type/export">数据备份</a></li>
  	        <li class="current"><a href="<?php echo U('Site/dataBase');?>/type/import">还原数据</a></li>
  	    </ul>
  	</div>
    <form id="export-form" action="<?php echo U('Site/export');?>" method="post">
      <div class="table_list">
        <table width="100%">
          <colgroup>
          <col width="40">
          <col width="40">
          <col width="270">
          <col width="170">
          <!-- <col width="100">
          <col width="50"> -->
          <col width="80">
          <col width="160">
          </colgroup>
          <thead>
            <tr>
              <td width="200" align="center">备份名称</td>
              <td width="80" align="center">卷数</td>
              <td width="80" align="center">压缩</td>
              <td width="80" align="center">数据大小</td>
              <td width="200" align="center">备份时间</td>
              <td width="80" align="center">状态</td>
              <td width="120" align="center">操作</td>
            </tr>
          </thead>
          <tbody>
            <?php if(is_array($lists)): $i = 0; $__LIST__ = $lists;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
              <td align="center"><?php echo (date('Ymd-His',$vo["time"])); ?></td>
              <td align="center"><?php echo ($vo["part"]); ?></td>
              <td align="center"><?php echo ($vo["compress"]); ?></td>
              <td align="center"><?php echo (format_size($vo["size"])); ?></td>
              <td align="center"><?php echo ($key); ?></td>
              <td align="center">-</td>
              <td align="center" class="action">
                  <a class="db-import" href="<?php echo U('sendEmail');?>/time/<?php echo ($vo["time"]); ?>">发送的指定邮箱</a>&nbsp;|&nbsp;
                  <a class="db-import" href="<?php echo U('import');?>/time/<?php echo ($vo["time"]); ?>">还原</a>&nbsp;|&nbsp;
                  <a class="J_ajax_del" data="<?php echo ($vo["time"]); ?>" datatitle="<?php echo (date('Ymd-His',$vo["time"])); ?>" href="<?php echo U('delData');?>">删除</a>
              </td>
            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
          </tbody>
        </table>
        <!-- <div class="p10"><div class="pages"> <?php echo ($Page); ?> </div> </div> -->

      </div>
      <!-- <div class="btn_wrap">
        <div class="btn_wrap_pd">
          <button class="btn btn_submit mr10" id="J_ajax_export" type="button">开始备份</button>
          <button data="<?php echo U('optimize');?>" class="btn btn_submit mr10" id="J_ajax_optimize" type="button">优化表</button>
          <button data="<?php echo U('repair');?>" class="btn btn_submit mr10" id="J_ajax_repair" type="button">修复表</button>
          <div style="float:right;font-size: 16px;font-weight: bold;
  font-family: Microsoft YaHei,tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;text-align: center;height:32px;line-height:32px;color:#666;">数据库中共有<?php echo ($tables); ?>张表，共计<?php echo ($total); ?></div>
        </div>
      </div> -->
    </form>

</div>
<script type="text/javascript">
(function($){
    $('.J_ajax_del').on('click', function (e) {
      e.preventDefault();
      var title = $(this).attr('datatitle');
      var href = $(this).attr('href');
      var data = $(this).attr('data');
      layer.confirm('是否删除备份文件<span style="color:red;">['+title+']</span>', {icon: 3, title:'删除备份文件提示'}, function(index){


          layer.close(index);
          $.ajax({
          type: 'post',
          url: href,
          data : {time : data},
          dataType:"json",
          beforeSend: function(){
            layer.load(1);
          },
          success: function(data){
            layer.close(layer.load(1));
            if(!data.status){
              ITENY.alert('提示信息',data.info,2,'5000');

            } else {
              ITENY.alert('提示信息',data.info,1,'5000');
              setTimeout(function(){
                        ITENY.reloadPage(window);
                    },3000);

            }
          },
          error: function(data){
            layer.close(layer.load(1));
            ITENY.alert('提示信息',data.responseText,2,'5000');

          }
        });
      });
    });
    $(".db-import").click(function(){
        var self = this, status = ".";
        $.get(self.href, success, "json");
        window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
        return false;

        function success(data){
            if(data.status){
                if(data.gz){
                    data.info += status;
                    if(status.length === 5){
                        status = ".";
                    } else {
                        status += ".";
                    }
                }
                $(self).parent().prev().text(data.info);
                if(data.part){
                    $.get(self.href,
                        {"part" : data.part, "start" : data.start},
                        success,
                        "json"
                    );
                }  else {
                    window.onbeforeunload = function(){ return null; }
                }
            } else {
                ITENY.alert('提示',data.info,2,'3000');
            }
        }
    });
})(jQuery);

</script>
</body>
</html>